Skip to content

feat(ai): add vector embeddings semantic RAG and adaptive quiz ML endpoints - #326

Open
anayashah2106 wants to merge 4 commits into
mainfrom
feature/adaptive-ai-vector-rag
Open

anayashah2106 wants to merge 4 commits into
mainfrom
feature/adaptive-ai-vector-rag

Conversation

@anayashah2106

Copy link
Copy Markdown
Collaborator

Summary

Upgrades ai-service/ with Gemini Vector Embeddings semantic search (gemini-embedding-2 / gemini-embedding-001) and adds the Python ML & RAG helper endpoints for the Adaptive AI Quiz.

Changes

  • Semantic Vector RAG (ai-service/embeddings_rag.py, ai-service/rag_service.py):
    • Added cosine-similarity vector retrieval using GeminiKeyRotator across gemini-embedding-2 and gemini-embedding-001 with automatic keyword-overlap fallback when offline or in AI_MOCK_ONLY mode.
    • Upgraded rag_service.search_relevant_chunks(...) to use semantic embedding retrieval.
  • Adaptive Quiz ML & RAG (ai-service/adaptive_ai.py):
    • Implemented auto_tag_question (AI_SUGGESTED subtopics & weights).
    • Implemented explain_adaptive_mistake grounded in course lecture transcripts with [mm:ss] timestamp citations.
    • Implemented generate_adaptive_question (AI_GENERATED structured MCQs targeting weak subtopics).
    • Implemented compute_tag_cooccurrence using normalized PMI across subtopic tag sets.
  • Flask Routes (ai-service/app.py):
    • Added POST /search/semantic, POST /adaptive/auto-tag, POST /adaptive/explain-mistake, POST /adaptive/generate-question, and POST /adaptive/cooccurrence.
  • Tests (ai-service/test_adaptive_ai.py):
    • Added unit tests for cosine similarity, semantic search fallback, PMI co-occurrence ordering, and all new Flask routes (python -m unittest discover -v passing).

Closes

Closes #324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Vector Embeddings Semantic RAG & Adaptive Quiz ML Layer in ai-service

1 participant